package cn.com.xjnt.vas.ordering.domain.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.com.xjnt.vas.manage.domain.entity.Organization;

/**
 * The persistent class for the ordering_food_seller database table.
 * 
 */
@Entity
@Table(name = "ordering_food_seller")
@NamedQuery(name = "FoodSeller.findAll", query = "SELECT f FROM FoodSeller f")
public class FoodSeller extends com.frameworks.core.entity.IdEntity {
    private static final long serialVersionUID = 1L;

    private String address;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    private int foodType;

    private String information;

    private String name;

    private String scope;

    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    
    // bi-directional many-to-one association to Hospital
    @ManyToOne
    @JoinColumn(name = "hospital_id")
    private Hospital hospital;
    
    @ManyToOne
    @JoinColumn(name = "organization_id")
    private Organization organization;

/*    // bi-directional many-to-one association to FoodMenu
    @OneToMany(mappedBy = "foodSeller")
    private List<FoodMenu> foodMenus;

    // bi-directional many-to-one association to FoodOrder
    @OneToMany(mappedBy = "foodSeller")
    private List<FoodOrder> foodOrders;

    // bi-directional many-to-one association to SellerDiscount
    @OneToMany(mappedBy = "foodSeller")
    private List<SellerDiscount> sellerDiscounts;*/

    public FoodSeller() {
    }

    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public int getFoodType() {
        return this.foodType;
    }

    public void setFoodType(int foodType) {
        this.foodType = foodType;
    }

    public String getInformation() {
        return this.information;
    }

    public void setInformation(String information) {
        this.information = information;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getScope() {
        return this.scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
/*
    public List<FoodMenu> getFoodMenus() {
        return this.foodMenus;
    }

    public void setFoodMenus(List<FoodMenu> foodMenus) {
        this.foodMenus = foodMenus;
    }

    public FoodMenu addFoodMenus(FoodMenu foodMenus) {
        getFoodMenus().add(foodMenus);
        foodMenus.setFoodSeller(this);

        return foodMenus;
    }

    public FoodMenu removeFoodMenus(FoodMenu foodMenus) {
        getFoodMenus().remove(foodMenus);
        foodMenus.setFoodSeller(null);

        return foodMenus;
    }

    public List<FoodOrder> getFoodOrders() {
        return this.foodOrders;
    }

    public void setFoodOrders(List<FoodOrder> foodOrders) {
        this.foodOrders = foodOrders;
    }

    public FoodOrder addFoodOrder(FoodOrder foodOrder) {
        getFoodOrders().add(foodOrder);
        foodOrder.setFoodSeller(this);

        return foodOrder;
    }

    public FoodOrder removeFoodOrder(FoodOrder foodOrder) {
        getFoodOrders().remove(foodOrder);
        foodOrder.setFoodSeller(null);

        return foodOrder;
    }

    public List<SellerDiscount> getSellerDiscounts() {
        return this.sellerDiscounts;
    }

    public void setSellerDiscounts(List<SellerDiscount> sellerDiscounts) {
        this.sellerDiscounts = sellerDiscounts;
    }

    public SellerDiscount addSellerDiscount(SellerDiscount sellerDiscount) {
        getSellerDiscounts().add(sellerDiscount);
        sellerDiscount.setFoodSeller(this);

        return sellerDiscount;
    }

    public SellerDiscount removeSellerDiscount(SellerDiscount sellerDiscount) {
        getSellerDiscounts().remove(sellerDiscount);
        sellerDiscount.setFoodSeller(null);

        return sellerDiscount;
    }*/

    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    public Hospital getHospital() {
        return hospital;
    }

    public void setHospital(Hospital hospital) {
        this.hospital = hospital;
    }

    @PrePersist
    public void onCreate() {
        this.createTime = this.updateTime = new Date();
    }

    @PreUpdate
    public void onUpdate() {
        this.updateTime = new Date();
    }
}